<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>munmap</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_850">&nbsp;</a>NAME</h4><blockquote>
munmap - unmap pages of memory
</blockquote><h4><a name = "tag_000_007_851">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="sysmman.h.html">sys/mman.h</a>&gt;

int munmap(void *<i>addr</i>, size_t <i>len</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_852">&nbsp;</a>DESCRIPTION</h4><blockquote>
The function
<i>munmap()</i>
removes any mappings for
those entire pages containing any part of the
address space
of the process starting at
<i>addr</i>
and continuing for
<i>len</i>
bytes.
Further references to these pages result in the
generation of a SIGSEGV signal to the process.
If there are no mappings in the specified address range,
then
<i>munmap()</i>
has no effect.
<p>
The implementation
&nbsp;will
require that
<i>addr</i>
be a multiple of the page size {PAGESIZE}.
<p>
If a mapping to be removed was private,
any modifications made in this address range will be discarded.
<p>
Any memory locks (see
<i><a href="mlock.html">mlock()</a></i>
and
<i><a href="mlockall.html">mlockall()</a></i>)
associated with this address range will be removed,
as if by an appropriate call to
<i><a href="munlock.html">munlock()</a></i>.
<p>
The behaviour of this function is unspecified
if the mapping was not established by a call to
<i><a href="mmap.html">mmap()</a></i>.
</blockquote><h4><a name = "tag_000_007_853">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>munmap()</i>
returns 0.  Otherwise, it returns -1 and sets
<i>errno</i> to indicate the error.
</blockquote><h4><a name = "tag_000_007_854">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>munmap()</i>
function will fail if:
<dl compact>

<dt>[EINVAL]<dd>
Addresses in the range [<i>addr, addr + len</i>) are outside the valid
range for the address space of a process.

<dt>[EINVAL]<dd>The <i>len</i> argument is 0.

<dt>[EINVAL]<dd>The <i>addr</i> argument is not a multiple of the page size as returned by
<i><a href="sysconf.html">sysconf()</a></i>.

</dl>
</blockquote><h4><a name = "tag_000_007_855">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_856">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The third form of EINVAL above is marked EX because it is defined as an
optional error in the POSIX Realtime Extension.
</blockquote><h4><a name = "tag_000_007_857">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_858">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="mmap.html">mmap()</a></i>,
<i><a href="sysconf.html">sysconf()</a></i>,
<i><a href="signal.h.html">&lt;signal.h&gt;</a></i>,
<i><a href="sysmman.h.html">&lt;sys/mman.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
